import java.util.Scanner;

public class Demo23 {
    public static void main(String[] args) {
        Object locker = new Object();
        Thread t1 = new Thread(() -> {
            synchronized (locker) {
                System.out.println("t1 wait 之前");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t1 wait 之后");
            }
        });

        Thread t2 = new Thread(() -> {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入任意内容唤醒 t1");
            scanner.next();

            synchronized (locker) {
                locker.notify();
            }
        });

        t1.start();
        t2.start();
    }
}
